package org.istt.domain;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * ProcessStatus entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "TBL_PROCESS_STATUS", schema = "dbo", catalog = "onegate")
public class ProcessStatus extends BaseObject<Long> implements
		java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2505970484947337329L;
	// Fields

	private Long id;
	private String status;
	//private Set<WorkflowProcess> workflowProcesses = new HashSet<WorkflowProcess>(0);
	private String description;
	private Float processTime;
	
	/*Transient property similar to workflow_process entity used in WorkflowAction*/
	private boolean used;
	private WorkflowProcess workflowProcess;
	
	// Constructors

	/** default constructor */
	public ProcessStatus() {
	}

	/** full constructor */

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "STATUS", length = 200)
	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	/*@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "processStatus")
	public Set<WorkflowProcess> getWorkflowProcesses() {
		return this.workflowProcesses;
	}

	public void setWorkflowProcesses(Set<WorkflowProcess> workflowProcesses) {
		this.workflowProcesses = workflowProcesses;
	}*/
	
	@Transient
	public boolean isUsed() {
		return used;
	}

	public void setUsed(boolean used) {
		this.used = used;
	}
	
	@Transient
	public WorkflowProcess getWorkflowProcess() {
		return workflowProcess;
	}

	public void setWorkflowProcess(WorkflowProcess workflowProcess) {
		this.workflowProcess = workflowProcess;
	}
	
	@Column(name = "DESCRIPTION", columnDefinition = "nvarchar(1000)")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "REQUIRED_DAY")
	public Float getProcessTime() {
		return processTime;
	}
	
	public void setProcessTime(Float processTime) {
		this.processTime = processTime;
	}

	public boolean equals(Object o) {
		if (this == o) return true;
		if (!(o instanceof ProcessStatus)) return false;

		final ProcessStatus ps = (ProcessStatus) o;


        if (!getStatus().equals(ps.getStatus())) return false;

		return true;
	}

	public int hashCode() {
		int result;
		result = status.hashCode();
		result = 29 * result;
		return result;
	}

	@Override
	public String toString() {
		return new StringBuilder("id = ").append(id)
					.append(", status = ").append(status)
					.toString();
	}

}